using System;
using System.Collections.Generic;
using System.Text;
using TrainTicket.DAO;
using TrainTicket.VO;
using System.Data;

namespace TrainTicket.TRAIN
{
    public class FaqTRAIN
    {
        private FaqDAO _faqDAO;
        public FaqTRAIN()
        {
            _faqDAO = new FaqDAO();
        }
        public DataTable GetAllFaq()
        {
            return _faqDAO.GetAllFaq();
        }
        public FAQ GetFaqById(int FaqId)
        {
            DataTable dbTable = _faqDAO.GetFaqById(FaqId);
            FAQ faq = new FAQ();

            foreach (DataRow dr in dbTable.Rows)
            {
                faq.FaqID = int.Parse(dr["FaqId"].ToString());
                faq.Questions = dr["Question"].ToString();
                faq.Answers = dr["Answers"].ToString();
            }
            return faq;
        }

        public DataSet FaqPagingSQL(int currPage, int recodperpage, int Pagesize)
        {
            return _faqDAO.FaqPagingSQL(currPage, recodperpage, Pagesize);
        }

        public int InsertFaq(string Questions,string Answers)
        {
           return _faqDAO.InsertFaq(Questions,Answers);
        }

        public int DeleteFaq(int FaqID)
        {
           return _faqDAO.DeleteFaq(FaqID);
        }
      
        public int UpdateFaq(int FaqID, string Questions, string Answers)
        {
           return _faqDAO.UpdateFaq(FaqID,Questions,Answers);
        }

        public bool CheckFaqExitsInsert(string Question)
        {
            int check = _faqDAO.CheckFaqExitsInsert(Question);
            if (check > 0)
                return true;
            else
                return false;
        }

        public bool CheckFaqExitsUpdate(int FaqID, string Question)
        {
            int check = _faqDAO.CheckFaqExitsUpdate(FaqID, Question);
            if (check > 0)
                return true;
            else
                return false;
        }        
   }
}
